// 水族商品推荐
function dogGoodsRecommend() {
    var type = 1,
        floor = 0,
        showResult = {}
    $.ajax({
        type: 'get',
        url: 'http://localhost:3000/fish/getRecommend',
        data: {
            type,
            floor
        },
        dataType: 'json',
        success: function(data) {
            // console.log(data);
            showResult[type] = data.data
            var html = ''
            if (data.code) {
                data.data.forEach((item) => {
                    html += `<dl class="first">
                    <dt>
                            <a href="javascript:;">
                                <img src="${item.image}" alt="">
                            </a>
                        </dt>
                    <dd>
                        <a href="javascript:;">${item.title}</a>
                    </dd>
                    <dd>
                        <span class="l">¥ ${item.price}</span>
                        <span class="r">已售${item.sales}</span>
                    </dd>
                </dl>`
                })
                $('.dogbox2').html(html)
            }
        }
    })
    $('.dogmond2 a').on('mouseover', function() {
        $(this).addClass('active1').siblings().removeClass('active1')
        type = $(this).attr('data-type')
            // console.log(type);
        if (showResult[type]) {
            var html = ''
            showResult[type].forEach((item) => {
                html += `<dl class="first">
                        <dt>
                                <a href="javascript:;">
                                    <img src="${item.image}" alt="">
                                </a>
                            </dt>
                        <dd>
                            <a href="javascript:;">${item.title}</a>
                        </dd>
                        <dd>
                            <span class="l">¥ ${item.price}</span>
                            <span class="r">已售${item.sales}</span>
                        </dd>
                    </dl>`
            })
            $('.dogbox2').html(html)
        } else {
            $.ajax({
                type: 'get',
                url: 'http://localhost:3000/fish/getRecommend',
                data: {
                    type,
                    floor
                },
                dataType: 'json',
                success: function(data) {
                    // console.log(data);
                    showResult[type] = data.data
                    var html = ''
                    if (data.code) {
                        data.data.forEach((item) => {
                            html += `<dl class="first">
                            <dt>
                                    <a href="javascript:;">
                                        <img src="${item.image}" alt="">
                                    </a>
                                </dt>
                            <dd>
                                <a href="javascript:;">${item.title}</a>
                            </dd>
                            <dd>
                                <span class="l">¥ ${item.price}</span>
                                <span class="r">已售${item.sales}</span>
                            </dd>
                        </dl>`
                        })
                        $('.dogbox2').html(html)
                    }
                }
            })
        }
    })
}

// 一楼 水族箱专区
function dogGrain() {
    var type = 1,
        floor = 1,
        showResult = {}
    $.ajax({
        type: 'get',
        url: 'http://localhost:3000/fish/getRecommend',
        data: {
            type,
            floor
        },
        dataType: 'json',
        success: function(data) {
            // console.log(data);
            showResult[type] = data.data
            var html = ''
            if (data.code) {
                data.data.forEach((item) => {
                    html += `<dl class="first">
                    <dt>
                            <a href="javascript:;">
                                <img src="${item.image}" alt="">
                            </a>
                        </dt>
                    <dd>
                        <a href="javascript:;">${item.title}</a>
                    </dd>
                    <dd>
                        <span class="l">¥ ${item.price}</span>
                        <span class="r">已售${item.sales}</span>
                    </dd>
                </dl>`
                })
                $('.grain').html(html)
            }
        }
    })
    $('.dogGrain li a').on('mouseover', function() {
        $(this).addClass('current').parent().siblings().children().removeClass('current')
        type = $(this).attr('data-type')
            // console.log(type);
        if (showResult[type]) {
            var html = ''
            showResult[type].forEach((item) => {
                html += `<dl class="first">
                        <dt>
                                <a href="javascript:;">
                                    <img src="${item.image}" alt="">
                                </a>
                            </dt>
                        <dd>
                            <a href="javascript:;">${item.title}</a>
                        </dd>
                        <dd>
                            <span class="l">¥ ${item.price}</span>
                            <span class="r">已售${item.sales}</span>
                        </dd>
                    </dl>`
            })
            $('.grain').html(html)
        } else {
            $.ajax({
                type: 'get',
                url: 'http://localhost:3000/fish/getRecommend',
                data: {
                    type,
                    floor
                },
                dataType: 'json',
                success: function(data) {
                    // console.log(data);
                    showResult[type] = data.data
                    var html = ''
                    if (data.code) {
                        data.data.forEach((item) => {
                            html += `<dl class="first">
                            <dt>
                                    <a href="javascript:;">
                                        <img src="${item.image}" alt="">
                                    </a>
                                </dt>
                            <dd>
                                <a href="javascript:;">${item.title}</a>
                            </dd>
                            <dd>
                                <span class="l">¥ ${item.price}</span>
                                <span class="r">已售${item.sales}</span>
                            </dd>
                        </dl>`
                        })
                        $('.grain').html(html)
                    }
                }
            })
        }
    })
}

// 二楼 饲料专区
function dogMedical() {
    var type = 1,
        floor = 2,
        showResult = {}
    $.ajax({
        type: 'get',
        url: 'http://localhost:3000/fish/getRecommend',
        data: {
            type,
            floor
        },
        dataType: 'json',
        success: function(data) {
            // console.log(data);
            showResult[type] = data.data
            var html = ''
            if (data.code) {
                data.data.forEach((item) => {
                    html += `<dl class="first">
                    <dt>
                            <a href="javascript:;">
                                <img src="${item.image}" alt="">
                            </a>
                        </dt>
                    <dd>
                        <a href="javascript:;">${item.title}</a>
                    </dd>
                    <dd>
                        <span class="l">¥ ${item.price}</span>
                        <span class="r">已售${item.sales}</span>
                    </dd>
                </dl>`
                })
                $('.dgcFloor-sl').html(html)
            }
        }
    })
    $('.dogMedical li a').on('mouseover', function() {
        $(this).addClass('current').parent().siblings().children().removeClass('current')
        type = $(this).attr('data-type')
            // console.log(type);
        if (showResult[type]) {
            var html = ''
            showResult[type].forEach((item) => {
                html += `<dl class="first">
                        <dt>
                                <a href="javascript:;">
                                    <img src="${item.image}" alt="">
                                </a>
                            </dt>
                        <dd>
                            <a href="javascript:;">${item.title}</a>
                        </dd>
                        <dd>
                            <span class="l">¥ ${item.price}</span>
                            <span class="r">已售${item.sales}</span>
                        </dd>
                    </dl>`
            })
            $('.dgcFloor-sl').html(html)
        } else {
            $.ajax({
                type: 'get',
                url: 'http://localhost:3000/fish/getRecommend',
                data: {
                    type,
                    floor
                },
                dataType: 'json',
                success: function(data) {
                    // console.log(data);
                    showResult[type] = data.data
                    var html = ''
                    if (data.code) {
                        data.data.forEach((item) => {
                            html += `<dl class="first">
                            <dt>
                                    <a href="javascript:;">
                                        <img src="${item.image}" alt="">
                                    </a>
                                </dt>
                            <dd>
                                <a href="javascript:;">${item.title}</a>
                            </dd>
                            <dd>
                                <span class="l">¥ ${item.price}</span>
                                <span class="r">已售${item.sales}</span>
                            </dd>
                        </dl>`
                        })
                        $('.dgcFloor-sl').html(html)
                    }
                }
            })
        }
    })
}

// 三楼 过滤器材
function dogLife() {
    var type = 1,
        floor = 3,
        showResult = {}
    $.ajax({
        type: 'get',
        url: 'http://localhost:3000/fish/getRecommend',
        data: {
            type,
            floor
        },
        dataType: 'json',
        success: function(data) {
            // console.log(data);
            showResult[type] = data.data
            var html = ''
            if (data.code) {
                data.data.forEach((item) => {
                    html += `<dl class="first">
                    <dt>
                            <a href="javascript:;">
                                <img src="${item.image}" alt="">
                            </a>
                        </dt>
                    <dd>
                        <a href="javascript:;">${item.title}</a>
                    </dd>
                    <dd>
                        <span class="l">¥ ${item.price}</span>
                        <span class="r">已售${item.sales}</span>
                    </dd>
                </dl>`
                })
                $('.glq').html(html)
            }
        }
    })
    $('.dogLife li a').on('mouseover', function() {
        $(this).addClass('current').parent().siblings().children().removeClass('current')
        type = $(this).attr('data-type')
            // console.log(type);
        if (showResult[type]) {
            var html = ''
            showResult[type].forEach((item) => {
                html += `<dl class="first">
                        <dt>
                                <a href="javascript:;">
                                    <img src="${item.image}" alt="">
                                </a>
                            </dt>
                        <dd>
                            <a href="javascript:;">${item.title}</a>
                        </dd>
                        <dd>
                            <span class="l">¥ ${item.price}</span>
                            <span class="r">已售${item.sales}</span>
                        </dd>
                    </dl>`
            })
            $('.glq').html(html)
        } else {
            $.ajax({
                type: 'get',
                url: 'http://localhost:3000/fish/getRecommend',
                data: {
                    type,
                    floor
                },
                dataType: 'json',
                success: function(data) {
                    // console.log(data);
                    showResult[type] = data.data
                    var html = ''
                    if (data.code) {
                        data.data.forEach((item) => {
                            html += `<dl class="first">
                            <dt>
                                    <a href="javascript:;">
                                        <img src="${item.image}" alt="">
                                    </a>
                                </dt>
                            <dd>
                                <a href="javascript:;">${item.title}</a>
                            </dd>
                            <dd>
                                <span class="l">¥ ${item.price}</span>
                                <span class="r">已售${item.sales}</span>
                            </dd>
                        </dl>`
                        })
                        $('.glq').html(html)
                    }
                }
            })
        }
    })
}

// 四楼 温控设备
function dogClean() {
    var type = 1,
        floor = 4,
        showResult = {}
    $.ajax({
        type: 'get',
        url: 'http://localhost:3000/fish/getRecommend',
        data: {
            type,
            floor
        },
        dataType: 'json',
        success: function(data) {
            // console.log(data);
            showResult[type] = data.data
            var html = ''
            if (data.code) {
                data.data.forEach((item) => {
                    html += `<dl class="first">
                    <dt>
                            <a href="javascript:;">
                                <img src="${item.image}" alt="">
                            </a>
                        </dt>
                    <dd>
                        <a href="javascript:;">${item.title}</a>
                    </dd>
                    <dd>
                        <span class="l">¥ ${item.price}</span>
                        <span class="r">已售${item.sales}</span>
                    </dd>
                </dl>`
                })
                $('.wdj').html(html)
            }
        }
    })
    $('.dogClean li a').on('mouseover', function() {
        $(this).addClass('current').parent().siblings().children().removeClass('current')
        type = $(this).attr('data-type')
            // console.log(type);
        if (showResult[type]) {
            var html = ''
            showResult[type].forEach((item) => {
                html += `<dl class="first">
                        <dt>
                                <a href="javascript:;">
                                    <img src="${item.image}" alt="">
                                </a>
                            </dt>
                        <dd>
                            <a href="javascript:;">${item.title}</a>
                        </dd>
                        <dd>
                            <span class="l">¥ ${item.price}</span>
                            <span class="r">已售${item.sales}</span>
                        </dd>
                    </dl>`
            })
            $('.wdj').html(html)
        } else {
            $.ajax({
                type: 'get',
                url: 'http://localhost:3000/fish/getRecommend',
                data: {
                    type,
                    floor
                },
                dataType: 'json',
                success: function(data) {
                    // console.log(data);
                    showResult[type] = data.data
                    var html = ''
                    if (data.code) {
                        data.data.forEach((item) => {
                            html += `<dl class="first">
                            <dt>
                                    <a href="javascript:;">
                                        <img src="${item.image}" alt="">
                                    </a>
                                </dt>
                            <dd>
                                <a href="javascript:;">${item.title}</a>
                            </dd>
                            <dd>
                                <span class="l">¥ ${item.price}</span>
                                <span class="r">已售${item.sales}</span>
                            </dd>
                        </dl>`
                        })
                        $('.wdj').html(html)
                    }
                }
            })
        }
    })
}
dogGoodsRecommend()
dogGrain()
dogMedical()
dogLife()
dogClean()